package com.jzo2o.foundations.controller.operation;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.foundations.model.dto.request.ServePageQueryReqDTO;
import com.jzo2o.foundations.model.dto.request.ServeTypePageQueryReqDTO;
import com.jzo2o.foundations.model.dto.request.ServeTypeUpsertReqDTO;
import com.jzo2o.foundations.model.dto.request.ServeUpsertReqDTO;
import com.jzo2o.foundations.model.dto.response.ServeResDTO;
import com.jzo2o.foundations.model.dto.response.ServeTypeResDTO;
import com.jzo2o.foundations.service.IServeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;

/**
 * @Author Ms.发发
 * @ClassName ServeController
 * @Date 2025/3/20 13:32
 * @Description 区域服务  控制层
 **/
@Validated
@RestController("operationServeController")
@RequestMapping("/operation/serve")
@Api(tags = "运营端 - 区域服务相关接口")
public class ServeController {

    @Resource
    private IServeService serveService;

    /***
     * @Author Ms.发发
     * @Description 区域服务分页查询
     * @param servePageQueryReqDTO
     * @Date 2025/3/20 13:40
     * @return {@link PageResult< ServeResDTO>}
     */
    @GetMapping("/page")
    @ApiOperation("区域服务分页查询")
    public PageResult<ServeResDTO> page(ServePageQueryReqDTO servePageQueryReqDTO) {
        return serveService.page(servePageQueryReqDTO);
    }


    /***
     * @Author Ms.发发
     * @Description putOnShelf  上架
     * @param id
     * @Date 2025/3/20 15:05
     */
    @PutMapping("/onSale/{id}")    //上下架状态， 0草稿 1：下架，:2：上架
    @ApiOperation("区域服务上架")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "服务id", required = true, dataTypeClass = Long.class),
    })
    public void putOnShelf(@PathVariable("id") Long id) {
        serveService.putOnShelf(id);
    }
    /***
     * @Author Ms.发发
     * @Description takeOffShelf  下架
     * @param id
     * @Date 2025/3/20 15:05
     */
    @PutMapping("/offSale/{id}")    //上下架状态， 0草稿 1：下架，:2：上架
    @ApiOperation("区域服务下架")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "服务id", required = true, dataTypeClass = Long.class),
    })
    public void takeOffShelf(@PathVariable("id") Long id) {
        serveService.takeOffShelf(id);
    }


    /***
     * @Author Ms.发发
     * @Description takeOffShelf  下架
     * @param id
     * @Date 2025/3/20 15:05
     */
    @PutMapping("/update/{id}")    //上下架状态， 0草稿 1：下架，:2：上架
    @ApiOperation("区域服务修改价格")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "服务id", required = true, dataTypeClass = Long.class),
            @ApiImplicitParam(name = "price", value = "价格", required = true, dataTypeClass = BigDecimal.class),
    })
    public void updatePrice(@PathVariable("id") Long id,@RequestParam("price") BigDecimal price) {
        serveService.updatePrice(id,price);
    }


    /****
     * @Author Ms.发发
     * @Description 批量新增
     * @param serveTypeUpsertReqDTOList
     * @Date 2025/3/20 20:44
     */
    @PostMapping("/batch")
    @ApiOperation("区域服务批量新增")
    public void batchAdd(@RequestBody List<ServeUpsertReqDTO> serveTypeUpsertReqDTOList) {
        serveService.batchAdd(serveTypeUpsertReqDTOList);
    }




    /***
     * @Author Ms.发发
     * @Description 删除区域服务
     * @param id
     * @Date 2025/3/20 18:35
     */
    @DeleteMapping("/{id}")
    @ApiOperation("区域服务删除")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "区域服务id", required = true, dataTypeClass = Long.class)
    })
    public void delete(@NotNull(message = "id不能为空") @PathVariable("id") Long id) {
        serveService.deleteById(id);
    }

    /***
     * @Author Ms.发发
     * @Description 设置热门
     * @param id
     */
    @PutMapping("/onHot/{id}")
    @ApiOperation("区域服务设置热门")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "服务id", required = true, dataTypeClass = Long.class),
    })
    public void onHot(@PathVariable("id") Long id) {
        serveService.onHot(id);
    }

    /***
     * @Author Ms.发发
     * @Description 取消热门
     * @param id
     */
    @PutMapping("/offHot/{id}")
    @ApiOperation("区域服务取消热门")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "服务id", required = true, dataTypeClass = Long.class),
    })
    public void offHot(@PathVariable("id") Long id) {
        serveService.offHot(id);
    }













}
